<?php
/*!
* TalkBack basic-client notification page. 
* This file shows how to use the talkback library to implement the notification page. 
* @Author: Elie Bursztein (elie _AT_ cs.stanford.edu)
* @version: 1.0
* @url: http://talkback.stanford.edu
* @Licence: LGPL
*/
?>

<?
require_once "config.php"; 				//configuration file
require_once "../library/talkback.php";	//the talkback cslient library 



//do we have variable ?
if (isset($_POST['action']) 
	and isset($_POST['crypto']) 
	and isset($_POST['version']) 
	and isset($_POST['sender_key']) 
	and isset($_POST['sender_signature'])
	) {

	//creating an instance of the lib
	$tb = new TalkBack($dataDir, $debug);

	//loading keyset
	//FIXME: load private key a sending time should be better
	$tb->load(TRUE); //we need our private key for forwarding

	//parse the notification
	$tb->parseNotification($_POST);
	
	//verify the crypto : public key and signature
	if ($tb->verifyNotification() == FALSE)
		die("Can't verify talkback notification, publicKey or signature is not correct\n");
	
	if ($debug) print "verified\n";
	//validate with the authority
	if ($tb->validateNotification() == FALSE)
		die("Can't validate talkback notification with the authority\n");
	//store it
	//$tb->storeNotification();
	print "Notification accepted, it should appears momentarily";

}
?>